- /* sxfbsins.cpp by K.Tsuru */
- // function ID 5204 BRADIX
- #ifndef SN_H
- #include "sn.h"
- #endif
- /**************
- SDecimal class
- sin x by series
- ***************/
- SDecimal BsinSeries(const SDouble& x){
- SDecimal dx;
- dx = dx.ConvToBin(x); // radix conversion
- SDecimal sum(dx), xsq, delta;
- ulong n = 4, den, mt = sum.SlOpMaxValue();
-
- xsq = dx*dx;
- XsDiv(xsq, 6, delta);
- delta *= dx;
- XXSub(sum, delta, sum);
-
- while(delta.Sign()){
- den = n*(n+1);
- if(den >= mt) break;
- delta *= xsq; // DDMult() is used.
-
- XsDiv(delta, den, delta);
- if(n & 2) XXSub(sum, delta, sum);
- else XXAdd(sum, delta, sum);
- n += 2;
- }
-
- while(delta.Sign()){
- if(n >= mt){
- sum.SetError(sum.NOT_CONVERGE,"BsinSeries", -5204);
- break;
- }
- delta *= xsq;
- XsDiv(delta, n, delta);
- XsDiv(delta, n+1, delta);
- if(n & 2) XXSub(sum, delta, sum);
- else XXAdd(sum, delta, sum);
- n += 2;
- }
- sum.upToTerm = n/2;
- return sum;
- }
sxfbsins.cpp : last modifiled at 2015/12/15 14:00:42(967 bytes)
created at 2015/12/22 16:09:56
The creation time of this html file is 2017/10/27 15:45:59 (Fri Oct 27 15:45:59 2017).